<?php

namespace App\Containers\AppSection\Data\Actions;

use App\Containers\AppSection\Data\UI\API\Requests\UpdateDocumentsRequest;
use App\Containers\AppSection\LegalForm\Tasks\UpdateLegalFormTask;
use App\Containers\AppSection\Log\Tasks\CreateLogTask;
use App\Ship\Parents\Actions\Action;

class UpdateDocumentsAction extends Action
{
    public function run(UpdateDocumentsRequest $request): array
    {
        $legalForm = app(UpdateLegalFormTask::class)->run($request->profile()->legal_form->id,
            ['documents' => $request->input('files')]);

        app(CreateLogTask::class)->run($request->profile()->id, 'Редактирование документов юр.лица', 'profile');

        return $legalForm;
    }
}
